package com.jiwei.community.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiwei.community.dao.SensitiveMapper;
import com.jiwei.community.entity.Sensitive;
import com.jiwei.community.service.SensitiveService;
import com.jiwei.community.utils.SensitiveWordUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * (Sensitive)表服务实现类
 *
 * @author jiwei
 * @since 2024-03-20 11:00:01
 */
@Service("sensitiveService")
public class SensitiveServiceImpl extends ServiceImpl<SensitiveMapper, Sensitive> implements SensitiveService {

    @Override
    public void refreshDFA() {
        List<Sensitive> sensitives = list();
        List<String> sensitiveStrList = sensitives.stream().map(Sensitive::getContent).collect(Collectors.toList());
        SensitiveWordUtils.root = SensitiveWordUtils.buildDfa(sensitiveStrList);
    }
}

